package 
{
	import away3d.cameras.*;
	import away3d.containers.*;
	import away3d.primitives.Plane;
	
	import flash.display.*;
	import flash.events.*;
	
	import jeu.terrains.CatanHexagone;
	import jeu.terrains.PanneauHex;

	[SWF(width=800, height = 600, backgroundColor = "#CCCCCC", framerate = "25")]
	
	public class CatanJeu extends Sprite
	{
		private var _view:View3D;
		private var _camera:HoverCamera3D;
		private var _catan:CatanHexagone;
		private var _catanListeTerr:PanneauHex;
			
		public function CatanJeu()
		{
			super();
			_catanListeTerr = new PanneauHex(0,0,100,100);
			initStage();
			init3D();
			initHexagone();
		}
		
		private function initStage():void 
		{
			stage.align = StageAlign.RIGHT;
			stage.quality = StageQuality.MEDIUM;
			stage.scaleMode = StageScaleMode.NO_SCALE;
		}
		
		private function init3D():void 
		{
			_camera = new HoverCamera3D();
			_camera.minTiltAngle = 15;
			_camera.maxTiltAngle = 65;
			
			_view = new View3D({width:0, height:0, x:0, y:0, camera:_camera});
			addChild(_view);
			
			addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		}
		
		private function initHexagone():void 
		{
			_view.scene.addChild(_catanListeTerr);
		}
		
		private function enterFrameHandler(e:Event):void 
		{
			_camera.panAngle = (this.stage.stageWidth * .5 - this.stage.mouseX) * .1 - 180;
			_camera.tiltAngle = (this.stage.stageHeight * .5 - this.stage.mouseY) * .5;
			_camera.hover();
			
			_view.render();
		}	
	}
}